#pragma once

#include <map>
#include <vector>

#include "CoCElementTexture.h"
#include "CoCElementMatrix.h"
#include "CoCElementColorTransform.h"
#include "CoCElementShape.h"
#include "CoCElementMovieClip.h"

class CoCMovieClipNode;
class CoCShapeNode;

enum CoCSWFTagType
{
	CCTT_NONE,
	CCTT_Texture = 1,
	CCTT_Shape = 18,
	CCTT_TextField = 7,
	CCTT_TextField2 = 15,
	CCTT_Matrix= 8,
	CCTT_ColorTransform = 9,
	CCTT_MovieClip= 12,
};

class CoCSWF
{
public:
	CoCSWF(void);
	~CoCSWF(void);

	void Reset();
	virtual bool LoadFromFile(const char *pFileName);
	virtual bool LoadFromMemory(void *data);
	void ExportTexture(const char *pDir);
	void ExportDebugData(const char *pDir, int nTag, int nIndex, void *data, int nLength);

	CoCElementTexture *GetTexture(char cID);
	CoCShapeNode *CreateShapeNodeByID(int nID);
	CoCShapeNode *CreateShapeNodeByIndex(int nIndex);
	int GetShapeCount();
	CoCMovieClipNode *CreateMovieClipByIndex(int nIndex);
	CoCMovieClipNode *CreateMovieClipByName(const char *pName);
	int GetMovieClipCount();
	const char *GetMovieClipNameByIndex(int nIndex);
	unsigned short GetMovieClipIndexByName(const char *pName);
	unsigned short GetMovieClipIndexByID(unsigned short ID);
	unsigned short GetShapIndexByID(unsigned short nID);
	unsigned short GetShapeIDByIndex(int nIndex);
	CoCElementMatrix *GetTrans(unsigned short nIndex);
	CoCElementColorTransform *GetColor(unsigned short nIndex);
	CoCElementMovieClip *GetMovieClipElementByName(const char *pName);
	CoCElementShape *GetShapeByID(unsigned short nID);

	std::vector<CoCElementTexture*> m_vecTextures;
	std::vector<CoCElementMatrix*> m_vecMatrix;
	std::vector<CoCElementColorTransform*> m_vecColorTransform;
	std::vector<CoCElementShape*> m_vecShap;
	std::vector<CoCElementMovieClip*> m_vecMovieClip;
	std::vector<unsigned short> m_ExportIDs;
	std::vector<std::string> m_ExportNames;
	std::vector<CoCElementMovieClip*> m_ExportMovieClip;
	std::map<unsigned short, unsigned short>  m_mapExportIndex;
	std::map<unsigned short, unsigned short>  m_mapShapIndex;
	std::map<unsigned short, unsigned short>  m_mapTextFiledIndex;

	std::string m_strFileName;
};

